/******************************************************************************************
 * Import
 ******************************************************************************************/

// module
import Taro, { Component } from '@tarojs/taro'

// project
import { CPage, CContent, CHeader, CFooter, CFloat, CAround, CBetween, CCenter, CRow, CWrap, CLine, CHand, CItemX, CItemY, CText, CLabel, CSvg, CImage, CButton, CColumn } from '../../../library/comp';
import { Base64, Gen, Time, Zip, Session, Storage, Http } from '../../../library/func';
import Icon from '../../../project/style/icon';
import DoHttp from '../../../project/func/http/http';

/******************************************************************************************
 * Export Class
 ******************************************************************************************/

export default class HelpList extends Component {

	/*------------------------------------------------------------------------------------
	 * 初始化
	 *-----------------------------------------------------------------------------------*/
	constructor(props) {
		super(props);

		/**
		 * state
		 */
		this.state = {
			helpList:[],
			
		}
	}

	/*------------------------------------------------------------------------------------
	 * 生命周期
	 *-----------------------------------------------------------------------------------*/
	// didMount
	componentDidMount() {
		DoHttp.get({
			url:'help/list.php',
			success:(data) => {
				this.setState({
					helpList:data
				})
			}
		})
	}
	
	/*------------------------------------------------------------------------------------
	 * 事件处理
	 *-----------------------------------------------------------------------------------*/
	// onNavigate 跳转到详情
	onNavigate = (url, e)=> {
		wx.navigateTo({
			url: url
		})
	}

	// 拨打客服电话
	phoneCall = ()=> {
		wx.makePhoneCall({
			phoneNumber: '0312-6785555' //要拨打的电话号码
		})
	}

	/*------------------------------------------------------------------------------------
	 * 自定义方法
	 *-----------------------------------------------------------------------------------*/
	config = {
        navigationBarTitleText: '帮助',
        navigationBarBackgroundColor: '#dd2f3c',
        navigationBarTextStyle: '#fff'
    }

	/*------------------------------------------------------------------------------------
	 * 渲染
	 *-----------------------------------------------------------------------------------*/
	render () {
		return (
			<CPage>
				<CContent bg='#f3f3f3'>
					
					{/* 帮助列表 */}
					<CColumn bg='#fff' >
						{/* 客服电话 */}
						<CBetween style='border-bottom:1px solid #e6e6e6;width:100%;' px='20' onClick={this.phoneCall} h='92' lh='92' >
							<CText size='28' color='#4d4d4d'>客服电话</CText>
							<CText color='#db505c' size='28' >0312-6785555</CText>
						</CBetween>
						{/* 列表循环 */}
						{this.state.helpList.map( item => {
							return (
								<CBetween style='border-bottom:1px solid #e6e6e6;width:100%;' px='20' onClick={this.onNavigate.bind(this,'/screen/user/help/detail?id='+item.id)} h='92' lh='92' >
									<CText size='28' color='#4d4d4d'>{item.set_name}</CText>
									<CSvg  w='30' h='30' color='#4e4e4e' icon={Icon.right}  />
								</CBetween>
							)
							
						})}
						
					</CColumn>

				</CContent>
			</CPage>
		)
	}
}


